package util

import "bytes"

func Merge(args ...string) string {
	buffer := bytes.Buffer{}
	for _, value := range args {
		buffer.WriteString(value)
	}
	return buffer.String()
}

func Join(a []string, sep string) []byte {
	switch len(a) {
	case 0:
		return []byte("")
	case 1:
		return []byte(a[0])
	}
	n := len(sep) * (len(a) - 1)
	for i := 0; i < len(a); i++ {
		n += len(a[i])
	}
	b := make([]byte, n)
	bp := copy(b, a[0])
	for _, s := range a[1:] {
		bp += copy(b[bp:], sep)
		bp += copy(b[bp:], s)
	}
	return b
}

func RemoveArrays(a []string, rele string) []string {
	b := make([]string, 0)
	for _, v := range a {
		if v != rele {
			b = append(b, v)
		}
	}
	return b
}
